package paket;

import java.io.IOException;
import java.util.HashMap;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import smarthouse.CommandManager;

import com.google.gson.Gson;

/**
 * Servlet implementation class FetchInitialValues
 */
public class FetchInitialValues extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public FetchInitialValues() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		int deviceId = Integer.parseInt(request.getParameter("deviceId"));
		int commandId = Integer.parseInt(request.getParameter("commandId"));
		HashMap<Integer, String> test =CommandManager.getInitialValuesForCommand(deviceId, commandId);
		Gson gson = new Gson();
		response.getWriter().write(gson.toJson(test));
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

}
